package com.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.FangchanxinxiDao;
import com.entity.Fangchanxinxi;
import com.service.FangchanxinxiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FangchanxinxiServiceImpl extends ServiceImpl<FangchanxinxiDao, Fangchanxinxi> implements FangchanxinxiService {

    @Resource
    private FangchanxinxiDao fangchanxinxiDao;



    @Override
    public Page page(Fangchanxinxi fangchanxinxi) {
        // 创建分页对象
        Page<Fangchanxinxi> page = new Page<>(fangchanxinxi.getPage(), fangchanxinxi.getLimit());
        // 创建查询条件（使用 EntityWrapper）
        EntityWrapper<Fangchanxinxi> wrapper = new EntityWrapper<>();
        String fangchanmingzi = fangchanxinxi.getFangchanmingzi();
        if(StringUtils.isNotBlank(fangchanmingzi)){
            wrapper.like("fangchanmingzi",fangchanmingzi);
        }
        List<Fangchanxinxi> fangchanxinxis = fangchanxinxiDao.selectPage(page, wrapper);
        page.setRecords(fangchanxinxis);
        return page;
    }


}
